#ifndef HIGHRISE_H_
#define HIGHRISE_H_

#include "Element.hpp"
#include "glew.h"
#include "Logger.hpp"
#include "Random.hpp"
#include "Shader.hpp"
#include "ShaderLibrary.hpp"
#include "TextureLibrary.hpp"
#include <string>
#include <iostream>
#include <assert.h>

using namespace std;

#include <vector>

class Shader;
class Texture;

class Highrise : public Element
{
public:
	Highrise();
	virtual ~Highrise() { }
	
	virtual void draw();
	virtual void drawShadow();
	virtual void drawSimple();
	
	virtual void generate( Random &r );
	
	void setGenerationRectangle( float x1, float x2, float y1, float y2 );

protected:
	void createLedges( Random &r );
	void createArc( Random &r );
	void createArrays();
	
	enum HighriseType { LEDGES=0, ARC=1, NUMBER_OF_TYPES=2 };
	
	
	Shader* m_shader;
	
	GLuint m_list;

	int numFaces;
	
	int m_floors;
	float m_width;
	float m_depth;
	float m_floorHeight;
	float m_x;
	float m_z;
	
	float m_maxWidth;
	float m_maxDepth;
	float m_nominalPositionX;
	float m_nominalPositionY;
	
	Texture* m_sides;

	
	class Quad {
	public:
		Quad( float nx, float ny, float nz,
			  float x0, float y0, float z0, float u0, float v0,
			  float x1, float y1, float z1, float u1, float v1,
			  float x2, float y2, float z2, float u2, float v2,
			  float x3, float y3, float z3, float u3, float v3 )
		{
			this->nx = nx;
			this->ny = ny;
			this->nz = nz;
			x[0] = x0; x[1] = x1; x[2] = x2; x[3] = x3;
			y[0] = y0; y[1] = y1; y[2] = y2; y[3] = y3;
			z[0] = z0; z[1] = z1; z[2] = z2; z[3] = z3;
			u[0] = u0; u[1] = u1; u[2] = u2; u[3] = u3;
			v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3;
		}
		
		float x[4], y[4], z[4];
		float nx, ny, nz;
		float u[4], v[4];
	};
	
	std::vector<Quad> m_quads;
	float* m_normals;
	float* m_uvs;
	float* m_verts;
};


#endif

